﻿using isky.dapper;
using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace isky.Plugin
{
    public class QuoteComparisonConditionPlugin:IPlugin
    {

        public void Execute(IServiceProvider serviceProvider)
        {
            // Obtain the execution context service from the service provider.
            var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            // Obtain the Organization Service factory service from the service provider
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            var service = factory.CreateOrganizationService(context.UserId);

            string inputArgument = context.InputParameters["InputParam"].ToString();
            try
            {
                QuoteComparsionDal quoteComparsionDal = new QuoteComparsionDal();

                string arearesult = quoteComparsionDal.GetAllAreaData("salesorder","new_quyu");
                string productresult= quoteComparsionDal.GetAllProductData();

                context.OutputParameters["QuoteAreaOut"] = arearesult;
                context.OutputParameters["YGCBProductOut"] = productresult;
            }
            catch (Exception ex)
            {
                context.OutputParameters["QuoteAreaOut"] = ex.Message;
            }

        }
    }
}
